<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>7计算百分比</title>
</head>

<body>

</body>
<script>
  "use strict";
  // 可以保留精确到多少位小数点的了
  function GetPercent(num, total) {
    return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00) + "%";
  }
  console.log(GetPercent(30, 65));
</script>

</html>